package com.tf;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 *
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.tf.temper","com.ccssoft.m8.common.ccssoft.modules.exception"})
public class TFtemperApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(TFtemperApplication.class, args);
        HttpMethod method = HttpMethod.GET;
        client("http://127.0.0.1:8099/logindevice/keep", method, null, null);
    }

    private static String client(String url, HttpMethod method, String body, HttpHeaders header)
    {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(15*1000);
        requestFactory.setReadTimeout(15*1000);
        RestTemplate client = new RestTemplate(requestFactory);
        HttpEntity<String> requestEntity = new HttpEntity<String>(body, header);
        ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class);
        return response.getBody();
    }
}

